会员可以在此提问,百战程序员老师有问必答
对大家有帮助的问答会被标记为“推荐”
看完课程过来浏览一下别人提的问题,会帮你学得更全面
截止目前,同学们一共提了 134090个问题
Python全系列/第九阶段:Python_Django2 框架(隐藏)/Django视图层 37922楼
Python全系列/第九阶段:Python_Django2 框架(隐藏)/Django视图层 37923楼

老师,我的代码按照视频中的敲的,但是出了问题,反复检查了几遍无结果还请老师帮忙看一下!

book.xsd中的代码:

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" >
	<xs:element name="books">
		<xs:complexType>   <!-- 复杂元素 -->
			<xs:sequence>
				<xs:element name="book" maxOccurs="unbounded"><!-- 第一个元素以及可以出现多个所以为unbounded -->
					<xs:complexType>
						<xs:sequence><!-- 子标签出现是有一定顺序的 -->
							<xs:element name="name" type="xs:string"></xs:element>
							<xs:element name="author" type="xs:string" ></xs:element>
							<xs:element name="price" type="xs:double"></xs:element>
						</xs:sequence>
						<xs:attribute name="id" type="xs:positiveInteger" use="required"></xs:attribute>
					</xs:complexType>
				</xs:element>
			</xs:sequence>
		</xs:complexType>
	</xs:element>
</xs:schema>

book.xml中的代码:

<?xml version="1.0" encoding="UTF-8"?>
<books xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 xsi:noNamespaceSchemaLocation="{book.xsd}">
	<book id="1001">
		<name>java开发实战</name>
		<author>江小欧</author>
		<price>99.9</price>
		
	</book>
	<book id="1002">
		<name>mysql从删库到跑路</name>
		<author>江小白</author>
		<price>89.7</price>
	</book>
</books>

Test类:

package cn.sxt.schema;

import java.io.File;
import java.io.IOException;

import javax.xml.bind.JAXBException;
import javax.xml.transform.Source;
import javax.xml.transform.stream.StreamSource;
import javax.xml.validation.Schema;
import javax.xml.validation.SchemaFactory;
import javax.xml.validation.Validator;

import org.xml.sax.SAXException;

public class Test92 {
	public static void main(String[] args) throws SAXException {
		//1.创建SchemaFactory工厂
		SchemaFactory sch = SchemaFactory.newInstance("http://www.w3.org/2001/XMLSchema");
		//2.建立验证文件对象
		File schemaFile = new File("book.xsd");
		//3.利用SchemaFactory工厂对象,接收验证的文件对象,生成Schema对象
		Schema schema = sch.newSchema(schemaFile);
		//4.生产对此schema的验证器
		Validator validator = schema.newValidator();
		//5.要验证的数据(准备数据源)
		Source source = new StreamSource();
		//6.开始验证
		try {
			validator.validate(source);
			System.out.println("成功");
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
			System.out.println("失败");
		}
	}
}


运行错误图:

blob.png



JAVA 全系列/第二阶段:JAVA 基础深化和提高/XML 技术(旧) 37924楼

game.rar

问题:按下键盘上下左右键,小飞机不移动,怎么解决?

JAVA 全系列/第一阶段:AI驱动的JAVA编程/飞机大战小项目训练 37925楼
Python全系列/第二阶段:Python 深入与提高/游戏开发-坦克大战 37928楼

老师,代码是照着敲的,可是运行的时候提示 'Tank' object has no attribute 'imges'

代码如下:

pygame
_display = pygame.display
COLOR_BLACK = pygame.Color(,,)    COLOR_RED = pygame.Color(,,)    version = MainGame():    window = SCREN_HWIDTH = SCREN_WIDTH = TANK_P1 = ():
        startGame():    _display.init()    MainGame.window = _display.set_mode([MainGame.SCREN_WIDTH,MainGame.SCREN_HWIDTH])    MainGame.TANK_P1 = Tank(, )  _display.set_caption(+ version)
        :
            MainGame.window.fill(COLOR_BLACK)    .getEvent()    MainGame.window.blit(.getTextSurface(%),(,))
            MainGame.TANK_P1.displayTanck()
            _display.update()  getEvent():    eventList = pygame.event.get()    event eventList:
            event.type == pygame.QUIT:
                .endGame()
            event.type ==  pygame.KEYDOWN:
                event.key == pygame.K_LEFT:    ()
                event.key == pygame.K_RIGHT:
                    ()
                event.key == pygame.K_UP:
                    ()
                event.key == pygame.K_DOWN:
                    ()
                event.key == pygame.K_SPACE:
                    ()
    getTextSurface(,text):
        pygame.font.init()
        font = pygame.font.SysFont(,)
        textSurface = font.render(text,,COLOR_RED)
        textSurface
    endGame():    ()
        ()    Tank():
    (,left,top):
        .iamges = {
            :pygame.image.load() , :pygame.image.load(),
            :pygame.image.load(),
            :pygame.image.load()
        }
        .directtion = .image = .imges[.directtion]    .rect = .image.get_rect()
        .rect.left = left
        .rect.top = top
    move():     shot():   displayTanck():        .image = .image[.directtion]
        MainGame.window.blit(.image,.rect)
MyTanck(Tank):    ():
        EnemyTank(Tank):    ():
        Bullet():    ():
        move():
        displayBulet():
        Explode():
    ():
        displayExplode():      Wall():    ():
        displayWall():
        Music():    ():
        MainGame().startGame()

运行结果:

blob.png

Python全系列/第二阶段:Python 深入与提高/游戏开发-坦克大战 37929楼
JAVA 全系列/(旧的隐藏)第七阶段:JAVA 高级技术/Linux 37930楼


pymysql
con=pymysql.connect()
cursor=con.cursor()
:
    spl=cursor.execute(sal)
    con.commit()
:
    ()
    con.rollback()
:
    con.close()

老师看看我这什么问题,我一执行就出现下面报错

Traceback (most recent call last):

  File "C:\Users\acer\AppData\Roaming\Python\Python37\site-packages\pymysql\connections.py", line 583, in connect

    **kwargs)

  File "C:\Program Files (x86)\Python37-32\lib\socket.py", line 707, in create_connection

    for res in getaddrinfo(host, port, 0, SOCK_STREAM):

  File "C:\Program Files (x86)\Python37-32\lib\socket.py", line 748, in getaddrinfo

    for res in _socket.getaddrinfo(host, port, family, type, proto, flags):

socket.gaierror: [Errno 11001] getaddrinfo failed


During handling of the above exception, another exception occurred:


Traceback (most recent call last):

  File "D:/python/pythondemo/com/插入数据.py", line 2, in <module>

    con=pymysql.connect('localhosrt','root','sen6263234','pythondemo',3306)

  File "C:\Users\acer\AppData\Roaming\Python\Python37\site-packages\pymysql\__init__.py", line 94, in Connect

    return Connection(*args, **kwargs)

  File "C:\Users\acer\AppData\Roaming\Python\Python37\site-packages\pymysql\connections.py", line 325, in __init__

    self.connect()

  File "C:\Users\acer\AppData\Roaming\Python\Python37\site-packages\pymysql\connections.py", line 630, in connect

    raise exc

pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhosrt' ([Errno 11001] getaddrinfo failed)")


Python全系列/第六阶段:数据库与AI协同技术实战/mysql的使用 37931楼
WEB前端全系列/预科阶段:职业规划/学习方法/程序员的职业规划 37935楼

课程分类

百战程序员微信公众号

百战程序员微信小程序

©2014-2025百战汇智(北京)科技有限公司 All Rights Reserved 北京亦庄经济开发区科创十四街 赛蒂国际工业园
网站维护:百战汇智(北京)科技有限公司
京公网安备 11011402011233号    京ICP备18060230号-3    营业执照    经营许可证:京B2-20212637