我有一个问题,如何在一行中打印文本和数据,在此脚本中什么显示了cpu的使用和磁盘可用空间:
public class UlamSpiral {
private static int firstNumber, secondNumber;
private static Scanner scanner = new Scanner(System.in);
public static void main(String[] args) {
getInput();
if(isPrime(firstNumber) || isPrime(secondNumber)){
System.out.println("Atleast one of the numbers are a prime number.");
} else {
//scenario when none are prime
}
}
public static void getInput() {
System.out.println("Enter two non-prime numbers");
firstNumber = scanner.nextInt();
secondNumber = scanner.nextInt();
}
public static boolean isPrime(int num) {
boolean flag = false;
for(int i = 2; i <= num / 2; ++i) {
// Condition for non-prime number.
if(num % i == 0) {
flag = true;
break;
}
}
return flag;
}
}
我希望将所有内容汇总为一行,以使其看起来像这样:
<% include partials/header %>
<div class="container" style="margin-top: 80px">
<h1 style="text-align: center;"> Add new Survey </h1>
<div id="container">
<form action="/surveys" method="POST">
<div class="form-group">
<input class="form-control" type="text" name="survey[name]" placeholder="Survey Name" >
</div>
<div class="form-group">
<input class="form-control" type="text" name="survey[image]" placeholder="Survey Image URL" >
</div>
<div class="form-group">
<input class="form-control" type="text" name="survey[description]" placeholder="Survey Description" >
</div>
<div class="form-group">
<button class="btn btn-lg btn-primary btn-block">Submit</button>
</div>
</form>
<div class="form-group">
<ul id="list">
</ul>
</div>
<a href="/survays">Go Back</a>
<form>
<select name="element">
<option value="type">Select Type</option>
<option value="trueFalse">True/False</option>
<option value="checkbox">CheckBox</option>
<option value="radio">Radio</option>
</select>
<input type="button" value="add" onclick="add(document.forms[1].element.value)"/>
</form>
</div>
</div>
<% include partials/footer %>
请帮助,谢谢
答案 0 :(得分:1)
import psutil
print 'MEM Usage:',psutil.virtual_memory().percent
print 'Disk Usage:',psutil.disk_usage('/').percent