- 1、本文档共12页,可阅读全部内容。
- 2、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
- 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
排行榜
1 你好
# 打开新窗口 , 输入 :
#! /usr/bin/python
# -*- coding: utf8 -*-
s1=input( Input your name: )
print ( 你好 ,%s % s1)
知识点 :
* input( 某字符串 ) 函数 : 显示 某字符串 , 并等待用户输入 .
* print() 函数 : 如何打印 .
* 如何应用中文
* 如何用多行注释
2 字符串和数字
但有趣的是 , 在 javascript 里我们会理想当然的将字符串和数字连接 , 因为是动态语言嘛 .
但在 Python 里有点诡异 ,如下 :
#! /usr/bin/python
a= 2
b= test
c= a+b
运行这行程序会出错 , 提示你字符串和数字不能连接 , 于是只好用内置函数进行转换
#! /usr/bin/python
# 运行这行程序会出错 , 提示你字符串和数字不能连接 ,于是只好用内置函数进行转换
a= 2
b= test
c= str(a)+b
d= 1111
e= a+int(d)
#How to print m ultiply values
print ( c is %s,e is %i % (c,e))
知识点 :
* 用 int 和 str 函数将字符串和数字进行转换
* 打印以 # 开头 , 而不是习惯的 //
* 打印多个参数的方式
排行榜
3 列表
#! /usr/bin/python
# -*- coding: utf8 -*-
# 列表类似 Javascript 的数组 , 方便易用
# 定义元组
word=[ a , b , c ,d , e , f , g ]
# 如何通过索引访问元组里的元素
a= word[2]
print ( a is: +a)
b= word[1:3]
print ( b is: )
print (b) # index 1 and 2 elements of word.
c= word[:2]
print ( c is: )
print (c) # index 0 and 1 elements of word.
d= word[0:]
print ( d is: )
print (d) # All elem ents of word.
# 元组可以合并
e= word[:2]+ word[2:]
print ( e is: )
print (e) # All elements of word.
f= word[-1]
print ( f is: )
print (f) # The last elem ents of word.
g= word[-4:-2]
print ( g is: )
print (g) # index 3 and 4 elements of word.
h= word[-2:]
print ( h is: )
print (h) # The last two elem ents.
i= word[:-2]
print ( i is: )
print (i) # Everything except the last two chara
您可能关注的文档
- 四川省遂宁市高中2018届零诊考试高三数学(文科答案).pdf
- 心理诊断技能案例分析.pdf
- 26字母标准手写体.pdf
- 值得终身背诵地经典国学100句.pdf
- 广东省深圳市耀华实验学校2018届高三上学期期中考试英语试题(实验班)+Word版含答案.pdf
- 小升初测试卷较难.pdf
- 新版北师大九年级数学上册期中测试卷.pdf
- 企业诊断--宝洁(中国)诊断分析报告(DOC6页).pdf
- 元音字母发音规则经典细则.pdf
- 七年级数学(上)期中测试卷_4.pdf
- 2023年东师幼儿心理学秋在线作业2满分.pdf
- 2024年普通高中学业水平合格性考试信息技术试卷6.pdf
- 2023-2024学年高中语文苏教版必修1第四专题 像山那样思考(文本研习)单元测试(含答案解析).pdf
- 2023吉林高校大学《辅导员》招聘考试模拟卷及答案.pdf
- 2023年江西省叉车司机职业资格N1考试试卷(含答案).pdf
- 2023年安全员-C证(广西壮族自治区)参考题库含答案卷4.pdf
- 2023年山东省青岛市莱西中考一模数学试题和答案详解.pdf
- 2023年度浙江省事业单位招聘考试《公共基础知识》考前练习题及答案.pdf
- 2022年江西省中考物理一模试题附解析.pdf
- 2024年吉林省专升本考试民法测试题含解析.pdf
文档评论(0)