出于某种原因,当我尝试从BytesIO蒸汽制作图像时,它无法识别图像.这是我的代码:
from PIL import Image, ImageGrab
from io import BytesIO
i = ImageGrab.grab()
i.resize((1280, 720))
output = BytesIO()
i.save(output, format = "JPEG")
output.flush()
print(isinstance(Image.open(output), Image.Image))
Run Code Online (Sandbox Code Playgroud)
它抛出的错误的堆栈跟踪:
Traceback (most recent call last):
File "C:/Users/Natecat/PycharmProjects/Python/test.py", line 9, in <module>
print(isinstance(Image.open(output), Image.Image))
File "C:\Python27\lib\site-packages\PIL\Image.py", line 2126, in open
% (filename if filename else fp))
IOError: cannot identify image file <_io.BytesIO object at 0x02394DB0>
Run Code Online (Sandbox Code Playgroud)
我正在使用PIL的Pillow实现.
我正在努力学习PyLatex.我已经通过pip安装它并从这里复制了基本代码,我遇到了这个问题:
C:\Conner\Scripts>pylatAttempt.py
latexmk: The script interpreter could not be found.
latexmk: Data: scriptInterpreter="perl.exe"
Traceback (most recent call last):
File "C:\Conner\Scripts\pylatAttempt.py", line 23, in <module>doc.generate_pdf()
File "C:\Python27\ArcGIS10.2\lib\site-packages\pylatex\document.py", line 193, in generate_pdf raise(e)
subprocess.CalledProcessError: Command '[u'latexmk', u'--pdf', u'--interaction=nonstopmode', u'basic.tex']' returned non-zero exit status 1
Run Code Online (Sandbox Code Playgroud)
我已经下载了MiKTeX 2.9,我还需要其他什么吗?这里出了什么问题?从文档看来,您需要安装的所有内容都是pylatex.
主类:
公共类二十一点{
static Deck D;
static Hand P;
public static void main(String[] args) {
init();
}
private static void init() {
D=new Deck();
P=new Hand(D);
startGame();
}
private static void startGame() {
System.out.print("Your cards are: "+P.H.get(0)+", "+P.H.get(1));
}
Run Code Online (Sandbox Code Playgroud)
}
手类:
import java.util.ArrayList;
import java.util.Random;
public class Hand {
ArrayList<String> H;
Random R;
public Hand(Deck D){
R=new Random();
H=new ArrayList<String>();
int C=R.nextInt(D.getP().length);
H.add(D.getP()[C]);
D.removeFromDeck(C);
int E=R.nextInt(D.getP().length);
H.add(D.getP()[E]);
D.removeFromDeck(E);
}
Run Code Online (Sandbox Code Playgroud)
}
甲板班
public class Deck {
String[] P;
public Deck(){
P=new String[52]; …Run Code Online (Sandbox Code Playgroud) 更新的代码:
import java.util.*;
public class Main {
/**
* @param args
*/
static int[] C;
static int[] D;
static String P;
public static void main(String[] args) {
C = new int[10];
D = new int[10];
getNumber();
}
private static void getNumber() {
System.out
.println("Enter your first number with spaces in between digits.");
Scanner S = new Scanner(System.in);
String O = S.nextLine();
String[] A = new String[10];
A = O.split(" ");
for (int X = 0; A.length > X; X++) { …Run Code Online (Sandbox Code Playgroud) 我正在尝试做的是将这样的东西转换"The Three Pigs"成这样的数组:
Array[0]="The"
Array[1]="Three"
Array[2]="Pigs"
Run Code Online (Sandbox Code Playgroud)
字符串类没有一个方法,我不知道如何自己做这个分裂似乎不适合我的目的,所以停止说它.示例代码:
import java.util.Scanner;
public class Main {
/**
* @param args
*/
public static void main(String[] args) {
GetNumber();
}
private static void GetNumber() {
System.out.println("Enter your words.");
Scanner S=new Scanner(System.in);
String O=S.next();
String[] A=O.split(" ");
for(int Y=0;A.length>Y;Y++){
System.out.println(A[Y]);
}
}
}
Run Code Online (Sandbox Code Playgroud)
这段代码会输出如果我放入The Little Pigs