#测试一个列表的for循环
#测试1
#深入的研究for循环你会发现,其实是程序每执行一次in后面的变量,并提取每次执行该变量中执行N次的字符位置。
zxc='a','b','c'
for i in zxc:
print(zxc)
#当打印in后面的变量时,print会显示出该变量的(字符所含有的总位数或元素数量*字符本身)
('a', 'b', 'c')
('a', 'b', 'c')
('a', 'b', 'c')
#因为是3个字符,所以打印3次,当打印变量i时,for语句是按zxc中的总元素数量来执行的,而每执行一次,就会提取其中第N个元素。
......................
阅读全部
|
qq935599717
贴于 2020年9月17日 04:50
hide
bbsi
#参考资料https://www.jb51.net/article/178869.htm
#修改python运行路径
#路径加载连接的三种方式:'/'、 ‘\' 、 r''
import os
os.chdir('C:/Users/86177/Desktop')
os.chdir(r'C:\Users\86177\Desktop')
os.chdir('C:\\Users\\86177\\Desktop')
#获得当前python程序运行路径
import os
print(os.getced())
#输出结果为:‘C:\Users\86177\Desktop'(当前程序在的路径)
......................
阅读全部
|
qq935599717
贴于 2020年9月14日 07:19
hide
bbsi
import os
files = os.listdir()
for file in files:
print(file, os.path.isdir(file))
阅读全部
|
qq935599717
贴于 2020年9月14日 07:05
hide
bbsi
武器\n")
# 练习一下循环的使用
for i in range(1, 21):
print("我爱编程中国 {0} 次".format(i))
阅读全部
|
孔三十六
贴于 2020年9月6日 17:14
hide
bbsi
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Time : 2019-01-20 22:23
# @Author : Apull
# @File : 佩奇.py
from turtle import *
def nose(x, y): # 鼻子
penup() # 提起笔
goto(x, y) # 定位
pendown() # 落笔,开始画
......................
阅读全部
|
apull
贴于 2020年8月9日 12:19
hide
bbsi
'''
1、求满足条件的两位数
809*??=800*??+9*?? 其中??代表的两位数, 809*??为四位数,8*??的结果为两位数,9*??的结果为3位数。求??代表的两位数,及809*??后的结果。
809乘以一个两位数 等于 800乘以这个两位数 加上 9乘以这个两位数。而且8乘以这个两位数的结果也是两位数。
输入:无
输出:
9708=809*12 = 800*12+9*12
'''
a = 809
for i in range(10,100):
b = i * a
......................
阅读全部
|
兽泪
贴于 2020年7月2日 17:37
hide
bbsi
print("我在中国学Python\n")
# 练习一下循环的使用
for i in range(1, 21):
print("我爱编程中国 {0} 次".format(i))
阅读全部
|
xxwyyf007
贴于 2020年6月23日 20:39
hide
bbsi
# 从控制台输入一个三个数,输出较大的值
print("请输入第一个数字")
num1=int(input())
print("请输入第二个数字")
num2=int(input())
print("请输入第三个数字")
num3=int(input())
if num2>num3:
if num1>num2:
print("输出最大值",num1)
else:
print("输出最大值",num2)
......................
阅读全部
|
SolitaryEag
贴于 2020年5月21日 11:38
hide
bbsi