小编use*_*777的帖子

python-为什么列表没有修改?

>>> c=[1,100,3]
>>>def nullity (lst):
   lst=[]
>>>nullity (c)
>>>c
[1,100,3]
Run Code Online (Sandbox Code Playgroud)

为什么c不返回[]?是不是nullity(c)意味着c=lst这样你都指向现在[]?

python python-3.x

4
推荐指数
1
解决办法
75
查看次数

如何生成n + 1长列表,填充0?

如何生成n + 1长列表,填充0?有什么看起来像list=[0]+(n+1)?

python list python-3.x

2
推荐指数
2
解决办法
100
查看次数

等同列表如何工作? - 可变的基本概念

为什么在以下情况下list2不是[3,5]

>>>list1=[3,5]
>>>list2=list1
>>>list1[0]=2
>>>list1
   [2,5]
>>>list2
   [2,5]
Run Code Online (Sandbox Code Playgroud)

但是当我在这里尝试它是[3,5]:

>>>list1=[3,5]
>>>list2=list1
>>>list1=[3,5,7]
>>>list2
   [3,5]
Run Code Online (Sandbox Code Playgroud)

python python-3.x

1
推荐指数
1
解决办法
1139
查看次数

如何使用str.join()?

>>>seq = ("a", "b", "c") # This is sequence of strings.
str.join( "-",seq )
SyntaxError: multiple statements found while compiling a single statement
Run Code Online (Sandbox Code Playgroud)

这里出了什么问题?我试图改变",'但它没有帮助...

>>> seq = ("a", "b", "c") 
my_string = "-"
str.join(my_string, seq)
SyntaxError: multiple statements found while compiling a single statement
Run Code Online (Sandbox Code Playgroud)

为什么?????

python string methods string-conversion

1
推荐指数
1
解决办法
1864
查看次数

在python中我**= 2意味着什么?它2 ^ i =我?

def f()
   i=2
   while i<len(l)
   i**=2
Run Code Online (Sandbox Code Playgroud)

在python中我**= 2意味着什么?它2 ^ i = i?

python python-3.x

1
推荐指数
1
解决办法
255
查看次数

为什么需要使用eval将3**631 + 29输入到int函数?

res=0
num=int(input("Enter a positive integer:"))
while num>0:
     res=res+(num % 10)
     num=num//10
 print (res)
Run Code Online (Sandbox Code Playgroud)

为什么输入3**631+29是有问题的?为什么可以eval解决这个问题?正如我所看到的,程序输出将显示"逐步"对输入整数中的数字进行求和,因此它3**631+29是不是整数而是字符串?但是为什么要eval参与?

python

0
推荐指数
1
解决办法
114
查看次数

标签 统计

python ×6

python-3.x ×4

list ×1

methods ×1

string ×1

string-conversion ×1