新手潘包邮
发表于 2018-5-12 08:43:28
def fun():
list1 =
lst = ""
for i in list1:
lst += str(i)
lst = lst[-1] + lst[:-1]
out = ""
for i in range(len(lst)//2):
out += lst + ","
out = out.split(",")
out_list = []
for i in out:
if i != "":
out_list.append(int(i))
return out_list
fun()
foxiangzun
发表于 2019-1-25 20:55:58
def rebuildList(list1) :
firstNum, lastNum = list1, list1[-1]
for i in range(1, len(list1)) :
temp1, temp2 = list1, list1
list1 = temp2 % 10 * 10 + temp1 // 10
list1.pop()
list1.insert(0, lastNum % 10 * 10 + firstNum // 10)
return list1
def showResult() :
temp = ''
list1 = []
print('请输入数字,按回车分隔,按\'q\'键结束:')
while True :
temp = input()
if temp == 'q' :
break
else :
list1.append(int(temp))
print('原列表为:', end='')
print(list1)
print('处理后的列表为:', end='')
print(rebuildList(list1))
showResult()
爱学习的喵
发表于 2019-1-25 22:59:22
本帖最后由 爱学习的喵 于 2019-1-25 23:01 编辑
最优化代码,同时处理2位以上问题
def fun167(array):
from math import log
first = %10*10**(log(array)//log(10)) + array//10)]
first.extend(%10*10**(log(array)//log(10)) + array//10) for i in range(1,len(array))])
return first
小贤啊哦
发表于 2020-6-4 21:36:24
def fun115(list1):
a=[]
b=[]
for i in list1:
first_bit=i//10
second_bit=i%10
a.append(str(first_bit))
b.append(str(second_bit))
result=[]
for j in range(1,len(b)):
result.append(int(b+a))
result.insert(0,int(b[-1]+a))
return result
kinkon
发表于 2022-9-7 15:52:36
def f167(arr):
s = ''.join(str(a) for a in arr)
s = s[-1] + s[:-1]
brr = list()
for i in range(0, len(s), 2):
brr.append(int(s))
return brr
arr =
print(f167(arr))