我正在尝试使用7zip扩展zip文件,但我一直在获取7zip Usage打印输出.
zip存在于c:\ temp中
同一命令在批处理窗口中成功:
C:\TEMP>7z x "tryThis.zip"
Run Code Online (Sandbox Code Playgroud)
我尝试将workdir路径添加到文件中,并且没有工作目录,没有任何帮助. - 我可以使用CMD/c命令运行它,但我更喜欢保持代码干净
我究竟做错了什么?
谢谢!
String pathTo7ZipExe = "c:\\program files\\7-zip\\7z.exe";
String fileName ="tryThis.zip";
String workingDir = "c:\\temp\\";
Process process = Runtime.getRuntime().exec(
new String[]{pathTo7ZipExe},
new String[]{" x \"" + fileName +"\""},
new File(workingDir));
BufferedReader in = new BufferedReader(new InputStreamReader(process.getInputStream()));
String line;
while ((line = in.readLine()) != null) {
System.out.println(line);
}
// wait for zip to end.
int exitVal = process.waitFor();
Run Code Online (Sandbox Code Playgroud) 我试图打印数字从1到10而不使用java中的循环.当n + 1传递给第6行的recursivefun方法调用时,它工作正常.但是当传递n ++时,代码会抛出一个错误:/
public class PrintWithoutUsingLoops {
public static void recursivefun(int n) {
if (n <= 10) {
System.out.println(n);
recursivefun(n++);//an exception is thrown at this line.
}
}
public static void main(String[] args) {
// TODO Auto-generated method stub
recursivefun(1);
}
}
Run Code Online (Sandbox Code Playgroud) 我无法在java中创建内部类对象:
package OOO;
class Car{
class Engine{
void display() {
System.out.println("this is inner diaplay() method");
}
}
}
public class Sample8InnerClassCar {
Car c = new Car();
Car.Engine e = c.new Car.Engine();
}
Run Code Online (Sandbox Code Playgroud)
它给我一个错误:无法分配成员类型Car.Engine.有人可以帮我理解更多吗?
我一直试图弄清楚这个问题的答案有什么问题.真的需要帮助!任何帮助表示赞赏!谢谢
题
a<b.a>b,程序将从b打印到a.如果b is the same as a,程序将要求用户输入另一个数字b,直到它不等于a.
Scanner sc = new Scanner(System.in);
System.out.println("Enter a: ");
int a = sc.nextInt();
System.out.println("Enter b: ");
int b = sc.nextInt();
if(a > b) {
for(int i = b; b >= a; b--) {
System.out.println(b);
}
} else if (a < b) {
for(int i = a; a <= b; a++) {
System.out.println(i);
}
} else {
System.out.println("Enter another number b: ");
int numberb = …Run Code Online (Sandbox Code Playgroud)因此,我试图通过不同类中的方法来编辑对象的x值。我这样做的真正原因要复杂得多,但我只是想简化事情。
我正在创建一个游戏,并且希望在整个游戏中更新属于第一类的对象。但是,当我尝试更新它时,它会出现在另一个类中,但是,一旦将范围返回到第一类,则x值将保持为0。
我已经为此努力了好几个小时...
public class first {
private second Second;
public void view() {
System.out.println(this.Second.x);
}
public void newObj() {
Second = new second();
}
public void changeObj() {
Second.changeX(4);
Second = Second.getSecond();
}
public static void main(String[] args) {
// TODO Auto-generated method stub
first First = new first();
First.newObj();
First.changeObj();
First.view();
}
}
public class second {
public static int x=0;
public second getSecond() {
return this;
}
public second(){
x=0;
}
public static void changeX(int x) { …Run Code Online (Sandbox Code Playgroud) 从Java开始,我希望创建时构造函数中的一个参数不超过某个值。举个例子 :
public class Vehicule {
protected String immat;
protected int poidsVide;
protected int charge;
protected int chargeMax;
Vehicule(String immat, int poidsVide, int charge) {
this.immat = immat;
this.poidsVide = poidsVide;
this.charge = charge;
this.chargeMax = 10000;
}
}
Run Code Online (Sandbox Code Playgroud)
我不希望任何带有“ charge”优于“ chargeMAx”实例的对象该怎么办?尝试了几种选择,到目前为止没有用。
谢谢你的帮助。
我的问题是我尝试合并两个列表:
alpha = ['red','white','blue']
beta = ['shirt','car','house']
Run Code Online (Sandbox Code Playgroud)
变成:
delta = ['red shirt','white car','blue house']
Run Code Online (Sandbox Code Playgroud)
我尝试使用zip(),但它返回:[('red', 'shirt'), ('white', 'car'), ('blue', 'house')]
这不是我想要的。
我该怎么做?先感谢您。
['baNaNa', 7] #字符串和步长 'utGtGt'# 字符串的每个字符按步长向后移动 import ast
in_string = input()
lis = ast.literal_eval(in_string)
st = lis[0]
step = lis[1]
alphabets = 'abcdefghijklmnopqrstuvwxyz'
password = ''
for letter in st:
if letter in alphabets:
index_val = alphabets.index(letter) - (step)
password += alphabets[index_val]
print(password)
Run Code Online (Sandbox Code Playgroud)
我得到的输出是“utgtgt”。我想要'utGtGt'。对此的帮助将不胜感激。
蟒蛇应用程序.py
Traceback (most recent call last):
File "app.py", line 1, in <module>
from chatbot import chatbot
File "C:\Users\hp\Desktop\try_projects\chat_bot\chatbot.py", line 1, in <module>
from chatterbot import ChatBot
ModuleNotFoundError: No module named 'chatterbot'
Run Code Online (Sandbox Code Playgroud)
代码是
from chatterbot import ChatBot
from chatterbot.trainers import ListTrainer, ChatterBotCorpusTrainer
chatbot= ChatBot('Crazy')
Run Code Online (Sandbox Code Playgroud)
这个问题的解决方案可能是什么?蟒蛇版本:3.8.3
我正在尝试删除传入消息中的所有标点符号,以便运行准确的审核系统。但是,当我使用 string.strip() 时,它只会去掉字符串的结束字符,并将同一字符的其余部分保留在字符串的其余部分中。我有什么误解吗?我能找到的每个资源都说 string.strip() 就足够了。
相关代码:
async def on_message(message):
stripString = ".!?,'@#$%^&*()"
if message.author == bot.user:
return
message.content = message.content.strip(variables.stripString)
Run Code Online (Sandbox Code Playgroud)
输入:这个。是。一个测试。
输出:这个。是。一个测试
java ×6
python ×4
7zip ×1
chatterbot ×1
constructor ×1
exception ×1
indexing ×1
loops ×1
python-3.x ×1
string ×1