随笔分类 - 零基础学python
摘要:1 # -*-coding:utf-8 -*- 2 from sys import argv 3 4 script, user_name, city = argv 5 rompt = ">>" #巧妙的提示符的运用 取一个变量名就ok了 6 7 print ("Hi %s, I'm the %s script." %(user_name, script)) 8 pr...
阅读全文
摘要:1 from sys import argv 2 3 script, frist, second, third = argv 4 5 print ("the script is called:",script) 6 print ("Your frist bus is:",frist) 7 print ("your second variable is:",second) ...
阅读全文
摘要:1 # -*-coding:utf-8 -*- 2 print ("how old are you?"),# python 3.0版本开始已经去掉了raw_input函数,直接用input函数就可以了 3 age = input("old?") 4 print ("how tall are you?"), 5 height = int(float(input())) #假如输...
阅读全文
摘要:1 # -*-coding:utf-8 -*- 2 print ("how old are you?"), 3 age = input() # python 3.0版本开始已经去掉了raw_input函数,直接用input函数就可以了 4 print ("how tall are you?"), 5 height = int(float(input())) #假如输入的是小数点...
阅读全文
摘要:1 ''' 2 tabby_cat = "\tI'm tabbed in." 3 persian_cat = "I'm split\non a line." 4 backslash_cat = "I'm \\ a \\ cat." 5 6 fat_cat = """ 7 I'll do a list: 8 \t* catfood 9 \t* Fishies 10 \...
阅读全文
摘要:#-*- coding:utf-8 -*- days = "mon Tue Wed Thu Fri Sat Sun" months = "Jan\vFeb\vMar\vApr\vMay\vJul\nJul\nAug" #开始熟悉转义序列的用法 这里用到的是\n ASCII 换行符 #\v ASCII 垂直制表符 print ("here are the days: ", days) p...
阅读全文
摘要:# -*- coding:utf-8 -*- formatter = "%s %s %s %s" #理解%s 和%r 输出时的不同 print (formatter % (1,2,3,4)) #python3.x与python2.x有一点区别,原来%(变量名,...)应该是加在print括号里 #如:print("who is the murder? %s or %s" % (a, b)...
阅读全文
摘要:# -*- coding:utf-8 -*- print ("Mary had a little lamb.") print ("its fleece was white as %s." % 'snow') print ("And everywhere that Mary went.") print ("+" * 1000 )# what'd that do? 这句话的写法要了解 end1 ...
阅读全文
摘要:# -*- coding:utf-8 -*- x = "there are %d type of people." % 10 #IndentationError: unexpected indent 格式没对齐 binary = "binary" do_not = "don't" y = "those who know %s and those who %s." % (binary,do_no...
阅读全文
摘要:# -*- coding:utf-8 -*- """my_name = 'tingfengyin' my_age = 35 # not a lie my_height = 74 #inches my_weight = 180 #lbs my_eyes = 'blue' my_teeth = 'white' my_hair = 'brown' print ("let's talk about %...
阅读全文
摘要:# -*- coding:utf-8 -*- #添加UTF-8编码 cars = 100 #变量cars有100辆 space_in_a_car = 4.0 #变量1辆车的空间可以容纳4个人 drives = 30# 变量司机有30名 passengers = 90 #乘客有90名 cars_not_driven = cars - drives #不开的车辆 cars_driven = ...
阅读全文
摘要:1 #_*_ coding: utf-8 _*_ #表示的是在脚本中使用unicode utf-8 编码 2 print ("hello world!") 3 print ("hello again") 4 print ("this is fun") 5 print ("yay! printing") 6 print ("i'd much rather you 'not'") 7 print ...
阅读全文
浙公网安备 33010602011771号