【Python学习之路】My first journey

来源:互联网 发布:蔡文静网络剧 编辑:程序博客网 时间:2024/05/19 20:38

作为一条大三咸鱼,过去的两年里我学了些什么东西,完全没有什么印象,然而,就是这样咸鱼的我,却喜欢上了机器学习(machine learning),不知是对是错,嘛,人生就应该不断地去学习才对,至于正不正确,有那么重要么?(也许很重要吧)

鉴于Python各种库对机器学习相关的算法和模型有很好的解释效果,于是,便开始的Python的学习,由于书买错了(大雾),于是转向线上学习,平台是runoob.com,感觉排版还不错,广告几乎没有,便于学习。至于学习内容,大概通篇是以代码的形式进行说明,加上注释,后面复习阅读也会看起来很直观,如果有大大觉得哪有不对的地方或者需要讨论的地方,欢迎留言和评论(^_^)以上。

# 注释1print("Hello Python!") # 注释2# 注释3# 注释4print("1") # 语句块里面才允许用缩进print("2") # 其他情况不允许缩进print("3") # 各个语句块之间的缩进空格要一致# Python的某一条语句很长的时候可以用反斜杠(\)来将一个语句拆成几行来写,当然,在括号里面的参数不需要反斜杠来作分开表示# Python四大数据类型:整型,长整型,浮点数,复数# 字符串中单双引号('', "")使用完全相同# 使用三引号(''', """)'''这是注释'''# 转义字符(\)使用可能'''换行:\netc'''# Python的语句结尾是自动换行的print("this line is auto")print("this line is auto\n")# 想要表达含有反斜杠(\)的字符串,可以通过在引号前面加上r或Rprint("you are an unbelievable man!  \n")print(r"you are an unbelievable man!  \n")print(R"you are an unbelievable man!  \n")# Python允许处理Unicode字符串,通过在其前面加u或者Uprint("\nthis is my first Unicode string")print(u"this is my first Unicode string")print(U"this is my first Unicode string")# Python的字符串不可更改# 同一语句的多个不同字符串直接连接print("\nthis ""is ""a ""complete ""sentence")# 等待user输入input("\npress any button to exit!")# Python可以在同一行显示多条语句,不过语句之间需要以分号(;)隔开print("\nthis is a"); print("separated sentence!"); import sys; x = 'separated sentence'; sys.stdout.write(x + ' make up one!\n')# Python实现输出语句末尾却不换行的做法是在语句末尾加上 end = ""print("\nthis is a new line")print("this is a new line", end="")print(", isn't it?\n")# 在 python 用 import 或者 from...import 来导入相应的模块。# 将整个模块(some module)导入,格式为: import some module# 从某个模块中导入某个函数,格式为: from some module import some function# 从某个模块中导入多个函数,格式为: from some module import first function, second function, third function# 将某个模块中的全部函数导入,格式为: from some module import# ex:导入sys模块import sysprint('================Python import mode==========================');print ('命令行参数为:')for i in sys.argv:    print (i)print ('\n python 路径为',sys.path)# 导入sys模块中的argv和path成员from sys import argv, path  # 导入特定的成员print('================python from import===================================')print(' path:', path)  # 因为已经导入path成员,所以此处引用时不需要加sys.path


原创粉丝点击