Python学习

作者: greatseniorsde | 来源:发表于2018-05-21 12:27 被阅读0次

    实习要写Python3,之前虽然用Python做过project但是不像java用的那么熟,现在临近实习开始,迅速跟个教程熟悉一下。

    tuple:Immutable, t = ('a',1,'a')
    list: can reassgin, l = [1,3,'b','b']
    set: on ordered unique
    Basic IO

    Userful operators:

    • range()
      mylist = [1,2,3]
      for num in range(0,10) 0 all the way to but including 10
      for num in range(0,10,2)
      range is a generator, eg: list(range(0,11,2))

    • enumrate

    index_count = 0
    for letter in 'abcde':
        print('At index {} the letter is {}'.format(index_count,letter))
        index_count += 1
    
    word = 'abcde'
    for item in enumerate(word):
        print(item)
    

    (0, 'a')
    (1, 'b')
    (2, 'c')
    (3, 'd')
    (4, 'e')

    • zip

    • in

    -max,min

    • from random import shuffle

    • from random import randint

    • input

    相关文章

      网友评论

        本文标题:Python学习

        本文链接:https://www.haomeiwen.com/subject/bjlfjftx.html