hackerrank杂记

https://www.hackerrank.com/challenges/py-set-discard-remove-pop/forum

  知识点:

  • *list:将list中的值取出,取出的数据大小是列表的长度,不是一个数据(*[1,2,3,4,5,]=1,2,3,4,5)
  • (*input().split()+[''])=(*(input().split()+['']))
  • def format(*args, **kwargs):接收不定长参数,参数可以多于要格式化写的数据个数,但不能少
  • (*map(int,'')):当map中要迭代的参数为空列表等,对该列表做int是没有用的,当取值时仍为空,但不会报错
  • sorted和sort的区别:sort不可放在for循环中直接排序,但是sorted可以
    • for i in sorted(itertools.permutations(A,int(num))):
    • for i in list(itertools.permutations(A,int(num))).sort():错误

  

原文地址:https://www.cnblogs.com/Mr-l/p/10733762.html