Home > other >  The python a great god, and write the python code into Java code, thank you
The python a great god, and write the python code into Java code, thank you

Time:10-03

Import a datetime, calendar, random, time
Def randomlist (arr) :
Length=len (arr)
If the length & lt; 1:
Return '
If length==1:
Return arr [0]
RandomNumber=random. Randint (0, length - 1)
Return int (arr [randomNumber])
Def the replace (arr) :
List=[]
For I in arr:
If I==0: list. Append (' rest ')
If I==1: list. Append (' morning ')
If I==2: list. Append (' night ')
Return a list
Def paiban () :
Start=input (" input YMD scheduling start time: ")
End=input (" input end of the scheduling time YMD: ")
DayCount=(datetime. Datetime. Strptime (end, "% Y % m % d)" - a datetime. Datetime. Strptime (start, "% Y % m % d)"). The days
Print (dayCount)
MonthRange=calendar. MonthRange (int (datetime. Datetime. Now (). The strftime (' % 'Y)), int (datetime. Datetime. Now (). The strftime (' % m)))
A1=[]; A2=[]; A3=[]
For I in range (1, monthRange [1] + 1) :
List=[0]
If I==1:
B1.=the random randint (0, 2)
List. Remove (int) (b1)
B2=randomlist (list)
List. Remove (int) (b2)
B3=randomlist (list)
If I==2:
If a1 [0]==0:
B1=random. Randint (1, 2)
List. Remove (b1)
If b1==a2 [0] :
B2=0
List. Remove (b2)
B3=randomlist (list)
If a2 [0]==0:
B2=random. Randint (1, 2)
List. Remove (b2)
If b2==a1 [0] :
B1=0
List. Remove (b1)
B3=randomlist (list)
If a3 [0]==0:
B3=random. Randint (1, 2)
List. Remove (b3)
If b3==a2 [0] : b2=0
List. Remove (b2)
B1=randomlist (list)
If I & gt;=3:
If a1 [I - 2]==0:
If a2 [I - 2] & gt; 0 and a2 [I - 3] & gt; 0:
B1=a2 [2] I -
List. Remove (b1)
B2=0
List. Remove (b2)
B3=randomlist (list)
The else:
B1=a3 [2] I -
B2=a2 [2] I -
B3=0
If a2 [I - 2]==0:
If a3 [I - 2] & gt; 0 and a3 [I - 3] & gt; 0:
B2=a3 [2] I -
List. Remove (b2)
B3=0
List. Remove (b3)
B1=randomlist (list)
The else:
B2=a1 [2] I -
List. Remove (b2)
B1=0
List. Remove (b1)
B3=randomlist (list)
If a3 [I - 2]==0:
If a1 [I - 2] & gt; 0 and a1 [I - 3] & gt; 0:
B3=a1 [2] I -
List. Remove (b3)
B1=0
List. Remove (b1)
B2=randomlist (list)
The else:
B3=a2 [2] I -
List. Remove (b3)
B2=0
List. Remove (b2)
B1=randomlist (list)
A1. Append (b1)
A2. Append (b2)
A3. Append (b3)
YM=datetime. Datetime. Now (). The strftime (' % % m Y ')
Print (" A staff scheduling information: % s \ nB staff scheduling information: % s \ nC staff scheduling information: % s "% (replace (a1), replace (a2), replace (a3)))
  • Related