-
for culture说:
报时
private static void speakTime(){ Calendar cal = Calendar.getInstance(); int hour = cal.get(Calendar.HOUR_OF_DAY); int minute = cal.get(Calendar.MINUTE); if(hour == 0){ System.out.println(String.format("现在是零点%s分", minute)); } else if(minute == 0){ System.out.println(String.format("现在是%s点整", hour)); } else { System.out.println(String.format("现在是%s点%s分", hour, minute)); } } // 判断是否是闰年 private static void isLeapYear(){ Scanner scanner = new Scanner(System.in); System.out.print("请输入年份:"); try { int year = scanner.nextInt(); if((year%4 == 0 && year%100 != 0) || year%400 == 0){ System.out.println(year + "年是闰年"); } else { System.out.println(year + "年不是闰年"); } } catch (Exception e){ System.out.println("请输入整数年份"); } }
}
-
for culture说:
报时
/// public class ReportTime { /// /// 报时 /// public static void Report() { var now = DateTime.Now; var hour = now.Hour; var min = now.Minute; if (min == 0) { Console.WriteLine($"现在是{hour}点"); } else { Console.WriteLine($"现在是{hour}点{min}分"); } } }
}
-
for culture说:
如下报错怎么解决
raise TypeError(context)
TypeError: None解决方法:
- 检查context变量是否有值,如果没有,则传入有意义的值;
- 检查上下文中的代码是否正确,以确定TypeError的原因;
- 尝试改变或重写上下文中的代码,以避免发生TypeError。